home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* Procedure to send/receive things to the tnc in block *)
- (* *)
- (* Copyright 1988, 1989, 1990 by H. Roy Engehausen. All rights reserved. *)
- (* This software may be freely distributed and used, but it may not *)
- (* under any circumstances be sold by anyone other than the author. *)
- (* It may be distributed by a commercial company as long as it is *)
- (* for no cost. *)
- (* *)
- (*===========================================================================*)
-
- PROCEDURE send_block_mode;
-
- TYPE
- over_array = ARRAY[1..512] OF BYTE;
-
- VAR
-
- byte_array : ^over_array;
- byte_count : WORD;
- set_dx : BYTE;
- times_up : LONGINT;
- tnc_registers : REGISTERS;
-
- BEGIN;
-
- stack_depth;
-
- {$IFDEF DEBUG_BLOCK}
- WINDOW(1,1,80,25);
- {$ENDIF}
-
- (*-----------------------------------------------------------------------*)
- (* Save the COM number for later use *)
- (*-----------------------------------------------------------------------*)
-
- set_dx := active_port^.com_number - 1;
-
- (*-----------------------------------------------------------------------*)
- (* Ok. Get addressing for transmit *)
- (*-----------------------------------------------------------------------*)
-
- WITH active_tcb^.tnc_htt^, tnc_registers DO
- BEGIN;
-
- (*-------------------------------------------------------------------*)
- (* See if junk around? *)
- (*-------------------------------------------------------------------*)
-
- AX := $0300;
- DX := set_dx;
-
- signal_place^ := $0200 + LO(signal_place^);
-
- INTR(tnc_interrupt, tnc_registers);
-
- signal_place^ := $F800 + LO(signal_place^);
-
- AH := AH AND lsr_8250_dr;
- IF AH <> 0 THEN
- window_write_critical('Garbage from TNC -- '
- + active_tcb^.port_chan_s
- + ' -- ',
- garbage_collect_tnc);
-
- (*-------------------------------------------------------------------*)
- (* Transmit it! *)
- (*-------------------------------------------------------------------*)
-
- AX := $0A00;
- CX := data_count + 4;
- DX := set_dx;
- DI := OFS(channel);
- ES := SEG(channel);
-
- {$IFDEF DEBUG_BLOCK}
- WRITELN('Send =', cx);
- WRITELN('Off=', di);
- byte_array := PTR(ES,DI);
- WRITE (ORD(byte_array^[1]),',');
- WRITE (ORD(byte_array^[2]),',');
- WRITE (ORD(byte_array^[3]),',');
- WRITE (ORD(byte_array^[4]),',');
- WRITE (ORD(byte_array^[5]),',');
- WRITE (ORD(byte_array^[6]),',');
- WRITE (ORD(byte_array^[7]),',');
- WRITE (ORD(byte_array^[8]),',');
- WRITELN(ORD(byte_array^[9]),',');
- {$ENDIF}
-
- signal_place^ := $0100 + LO(signal_place^);
-
- INTR(tnc_interrupt, tnc_registers);
-
- signal_place^ := $7800 + LO(signal_place^);
-
- {$IFDEF DEBUG_BLOCK}
- WRITELN('Return cx=', cx);
- WRITELN('Off=', di);
- {$ENDIF}
-
- END;
-
- (*-----------------------------------------------------------------------*)
- (* If this is master task then time check *)
- (*-----------------------------------------------------------------------*)
-
- IF master_thread THEN
- time_check;
-
- (*-----------------------------------------------------------------------*)
- (* If QRES then leave now. *)
- (*-----------------------------------------------------------------------*)
-
- IF qres_resp THEN
- EXIT;
-
- (*-----------------------------------------------------------------------*)
- (* Ok. Get addressing for receive *)
- (*-----------------------------------------------------------------------*)
-
- WITH active_tcb^.tnc_tth^, tnc_registers DO
- BEGIN;
-
- (*-------------------------------------------------------------------*)
- (* Prep the counter and timeouts *)
- (*-------------------------------------------------------------------*)
-
- times_up := up_time + time_out_value;
-
- byte_count := 0;
-
- (*-------------------------------------------------------------------*)
- (* Initialize *)
- (*-------------------------------------------------------------------*)
-
- CX := SIZEOF(tnc_to_host);
- DI := OFS(channel);
- ES := SEG(channel);
-
- byte_array := @channel;
- byte_count := 0;
-
- (*-------------------------------------------------------------------*)
- (* Loop reading the data *)
- (*-------------------------------------------------------------------*)
-
- WHILE TRUE DO
- BEGIN;
-
- task_switch;
-
- (*---------------------------------------------------------------*)
- (* Receive it *)
- (*---------------------------------------------------------------*)
-
- AX := $0B00;
- CX := SIZEOF(tnc_to_host) - byte_count;
- DX := set_dx;
-
- {$IFDEF DEBUG_BLOCK}
- WRITELN('BCX=', cx);
- WRITELN('BDI=', di);
- WRITELN('BES=', es);
- {$ENDIF}
-
- signal_place^ := $0200 + LO(signal_place^);
-
- INTR(tnc_interrupt, tnc_registers);
-
- signal_place^ := $F800 + LO(signal_place^);
-
- byte_count := byte_count + CX;
-
- {$IFDEF DEBUG_BLOCK}
- WRITELN('ACX=', cx);
- WRITELN('ADI=', di);
- WRITELN('AES=', es);
- WRITELN('byte_count=', byte_count);
- {$ENDIF}
-
- AH := AH AND lsr_8250_or;
- IF AH <> 0 THEN
- BEGIN;
- window_write_critical_i('Overrun block loop -- '
- + active_tcb^.port_chan_s
- + ' -- Count = ',
- byte_count);
- IF byte_count <= 5 THEN
- WHILE byte_count <= 10 DO
- BEGIN;
- INC(byte_count);
- byte_array^[byte_count] := $0;
- END;
- EXIT;
- END;
-
- IF master_thread THEN
- time_check;
-
- IF (times_up < up_time) AND (CX = 0) THEN
- BEGIN;
- window_write_critical_i('Timeout block loop -- '
- + active_tcb^.port_chan_s
- + ' -- Count = ',
- byte_count);
- IF byte_count <= 5 THEN
- WHILE byte_count <= 10 DO
- BEGIN;
- INC(byte_count);
- byte_array^[byte_count] := $0;
- END;
-
- EXIT;
- END;
-
- IF byte_count >= 2 THEN
- BEGIN;
-
- {$IFDEF DEBUG_BLOCK}
- WRITELN('Code=', tnc_code);
- WRITELN('lastchar=', ORD(byte_array^[byte_count]));
- {$ENDIF}
-
- IF tnc_code = 0 THEN EXIT;
-
- (*-----------------------------------------------------------*)
- (* If this is a null terminated response and it is a null, *)
- (* then we must be done *)
- (*-----------------------------------------------------------*)
-
- IF (byte_array^[byte_count] = 0) AND (tnc_code < 6) THEN
- EXIT;
-
- (*-----------------------------------------------------------*)
- (* Watch for weirdos *)
- (*-----------------------------------------------------------*)
-
- IF byte_count > 260 THEN
- BEGIN;
- WRITELN;
- WRITELN('Ser I/O Crash');
- WRITELN('Byte cnt = ', byte_count);
- WRITELN('AL = ', AL);
- WRITELN('Type = ', tnc_code);
- HALT;
- END;
-
- (*-----------------------------------------------------------*)
- (* If this is a data count response and the count is correct *)
- (* then we must be done *)
- (*-----------------------------------------------------------*)
-
- IF (byte_count >= (data67_count + 4)) AND (tnc_code >= 6)
- AND (byte_count > 2) THEN
- EXIT;
-
- END;
-
- END; (*----- End loop for receiving the response ------------------*)
-
- END;
-
- END;